package com.znh.kuiklyuniversity.compose.widgets

import androidx.compose.runtime.Composable
import com.tencent.kuikly.compose.foundation.Image
import com.tencent.kuikly.compose.foundation.background
import com.tencent.kuikly.compose.foundation.layout.Box
import com.tencent.kuikly.compose.foundation.layout.Column
import com.tencent.kuikly.compose.foundation.layout.Row
import com.tencent.kuikly.compose.foundation.layout.aspectRatio
import com.tencent.kuikly.compose.foundation.layout.fillMaxHeight
import com.tencent.kuikly.compose.foundation.layout.fillMaxSize
import com.tencent.kuikly.compose.foundation.layout.fillMaxWidth
import com.tencent.kuikly.compose.foundation.layout.height
import com.tencent.kuikly.compose.foundation.layout.padding
import com.tencent.kuikly.compose.foundation.layout.width
import com.tencent.kuikly.compose.foundation.shape.RoundedCornerShape
import com.tencent.kuikly.compose.material3.Text
import com.tencent.kuikly.compose.resources.DrawableResource
import com.tencent.kuikly.compose.resources.InternalResourceApi
import com.tencent.kuikly.compose.resources.painterResource
import com.tencent.kuikly.compose.ui.Alignment
import com.tencent.kuikly.compose.ui.Modifier
import com.tencent.kuikly.compose.ui.draw.clip
import com.tencent.kuikly.compose.ui.graphics.Brush
import com.tencent.kuikly.compose.ui.graphics.Color
import com.tencent.kuikly.compose.ui.unit.dp
import com.tencent.kuikly.compose.ui.unit.sp
import com.tencent.kuikly.core.base.BorderStyle
import com.tencent.kuikly.core.base.attr.ImageUri
import com.znh.kuiklyuniversity.Border
import com.znh.kuiklyuniversity.border
import com.znh.kuiklyuniversity.borderRadius
import com.znh.kuiklyuniversity.compose.mainPage.ListModel
import com.znh.kuiklyuniversity.compose.selfenum.AppColor

@OptIn(InternalResourceApi::class)
@Composable
fun PeopleWidget() {
    Column(
        modifier = Modifier.fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Box(modifier = Modifier.padding(top = 20.dp, bottom = 10.dp)) {
            Image(
                painter = painterResource(
                    DrawableResource(
                        ImageUri.commonAssets(
                            ListModel.dataUserList
                                .get(0)
                        ).toUrl("user icon")
                    )
                ),
                modifier = Modifier.width(72.dp).height(72.dp)
//                    .borderRadius(36.dp)
                    .clip(RoundedCornerShape(36.dp)),


//                    .aspectRatio(1f),
                contentDescription = ""
            )
        }

        Row {
            Text("用户名称", fontSize = 14.sp, color = Color.Black)
        }
        Row(modifier = Modifier.fillMaxWidth().height(36.dp)) {
            Box(modifier = Modifier.weight(1f), contentAlignment = Alignment.Center) {
                Text(
                    "24",
                    fontSize = 14.sp,
                    color = Color.Black
                )
            }
            Box(modifier = Modifier.weight(1f), contentAlignment = Alignment.Center) {
                Text(
                    "1564",
                    fontSize = 14.sp,
                    color = Color.Black
                )
            }


        }
        Row(modifier = Modifier.fillMaxWidth().height(36.dp)) {
            Box(modifier = Modifier.weight(1f), contentAlignment = Alignment.Center) {
                Text(
                    "上新",
                    fontSize = 14.sp,
                    color = AppColor.TxtSelColor.color
                )
            }
            Box(modifier = Modifier.weight(1f), contentAlignment = Alignment.Center) {
                Text(
                    "总数",
                    fontSize = 14.sp,
                    color = AppColor.TxtSelColor.color
                )
            }
        }

        Row(modifier = Modifier.fillMaxWidth().height(36.dp)) {
            Box(
                modifier = Modifier.weight(1f)
                    .fillMaxHeight()
                    .borderRadius(3.dp)
                    .background(brush = Brush.verticalGradient(listOf(AppColor.BgSelColor.color, Color.Transparent)))
                    .border(
                    Border(
                        lineWidth = 1.dp,
                        lineStyle = BorderStyle.DASHED,
                        color = AppColor.LineGreen.color
                    )
                ), contentAlignment = Alignment.Center
            ) { Text("会员权益", fontSize = 14.sp, color = Color.Black) }
            Box(
                modifier = Modifier.weight(1f)
                    .padding(start = 5.dp)
                    .background(brush = Brush.verticalGradient(listOf(AppColor.BgSelColor.color, Color.Transparent)))
                    .fillMaxHeight().borderRadius(3.dp).border(
                    Border(
                        lineWidth = 1.dp,
                        lineStyle = BorderStyle.DASHED,
                        color = AppColor.LineGreen.color
                    )
                ), contentAlignment = Alignment.Center
            ) { Text("积分商城", fontSize = 14.sp, color = Color.Black) }
        }
    }
}